package com.gandong8.es.tool.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.gandong8.es.tool.core.EsDoc;
import com.gandong8.es.tool.core.EsDocId;
import com.gandong8.es.tool.core.EsQuery;
//import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexRequest;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public interface EsService {
    boolean createIndex(Class<?> clazz);

    boolean createIndex(CreateIndexRequest request);

    boolean deleteIndex(Class<?> clazz);

    boolean deleteIndex(String indexName);

    boolean addDoc(EsDoc obj);


    boolean addDoc(String indexName, String sourceId, Map<String, Object> map);

    //EsDoc getDoc(EsDoc obj);

    void bulkAddDoc(EsDoc obj) throws JsonProcessingException;

    <T> T getDoc(EsDocId obj);

    <T extends EsDoc> T getDoc(String docId, Class<? extends EsDoc> clazz);

    boolean delDoc(EsDoc obj);

    void bulkDelDoc(EsDoc obj);

    boolean updateDoc(EsDoc obj);

    void bulkUpdateDoc(EsDoc obj);

    <T extends EsDoc> List<T> search(EsQuery<T> query) throws IOException;
}
